<template>
	<view class="container">
		<top-back-navbar position="fixed" title="资讯" background="" color="#ffff"></top-back-navbar>
		<cxsytabbars :current="1"></cxsytabbars>
		<view>
			<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="button"
				activeColor="#8251FF" class="nav_bar_box"></uni-segmented-control>
			<view class="content">
				<view class="view_box">
					<view class="box" v-for="item,index in data_list" @click="to_goos(item)">
						<view class="txt">
							{{item.article_title}}
						</view>
						<view class="" style="color: #dedede;">
							>
						</view>
					</view>
				</view>
				
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				data_list: [],
				openid: '',
				items: ['平台公告', '平台资料','操作视频' ],
				current: 0,
				type: 1,
			};
		},
		onLoad: function() {

			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.getdata()
				},
				fail: () => {
					uni.hideLoading()
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}
			});
		},
		methods: {
			to_goos(item){
				uni.navigateTo({
					url: '/pages/essay/essay?essaysid=' +item.id
				});
			},
			getdata() {
				var openid = this.openid
				var type = this.current + 1
				uni.request({
					url: this.$BASE_URL +
						'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=api.index.zixun&app=1&openid=' +
						openid + '&type=' + type,

					success: res => {
						var data = res.data
						var code = data.error
						console.log(data);
						this.data_list=data.list
					},
					fail: () => {},
					complete: () => {
						uni.hideLoading();
					}
				});
			},
			onClickItem(e) {
				if (this.current != e.currentIndex) {
					console.log(this.current);
					this.current = e.currentIndex;
					this.getdata()
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-size: 100% 100%;
		height: 100%;
		color: transparent;
	}

	.container {
	
		height:calc(100vh - 100rpx);
		background: url('/static/zn/hander_bg.png')0 0 no-repeat;
		// background-size: 150% 106%;
		
		background-size: 100%;
		background-color: #f8f8f8;
		position: relative;
		padding: 0 10px;
		overflow: auto;
		padding: 0 10px;
	}
	.content{
		width: 100%;
		background-color: #fff;
		padding: 25px 10px;
	}
		.nav_bar_box {
		background-color: #fff !important;
		height: 52px !important;
	}

	.view_box {
		height: calc(92vh - 100px);
		overflow: auto;
		color: #000;
		
		.box {
			
			width: 100%;
			background-size: cover;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			height: 40px;
			line-height: 40px;
			border-bottom:1px solid #ebebeb;
			.txt{
			
				    font-weight: 600;
			}
			
		}
	}
</style>